package tmproject.hlhj.fhp.tmvote.adapters

import android.graphics.Color
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import tmproject.hlhj.fhp.tmvote.Content
import tmproject.hlhj.fhp.tmvote.R
import tmproject.hlhj.fhp.tmvote.beans.VoteListBean
import tmproject.hlhj.fhp.tmvote.customView.RectImageView
import tmproject.hlhj.fhp.tmvote.network.Urls
import tmproject.hlhj.fhp.tmvote.utils.GlideUtils

/**
 * Created by Never Fear   on 2018\8\6 0006.
Never More....
 */
class VoteListAdp(datas:ArrayList<VoteListBean.DataBean.ListBean>):BaseQuickAdapter<VoteListBean.DataBean.ListBean,BaseViewHolder>
(R.layout.vote_list_item,datas) {
    override fun convert(helper: BaseViewHolder?, item: VoteListBean.DataBean.ListBean?) {
        helper?.setBackgroundRes(R.id.backImg,Content.vote_list_item_bac)
        helper?.setText(R.id.itemName,item?.title)
        val view = helper?.getView<TextView>(R.id.itemName)
        view?.setShadowLayer(1f,1f,1f,Color.parseColor(Content.shadow_Color))

        helper?.setText(R.id.itemName2,item?.title)
        if (item?.state.equals("1")){
            helper?.setText(R.id.itemTime,"活动时间：${item?.start_time}至${item?.end_time}")
        }else{
            helper?.setText(R.id.itemTime,"报名时间：${item?.enroll_start}至${item?.enroll_end}")
        }
        val img = helper?.getView<RectImageView>(R.id.itemImg)
        item?.activity_cover?.let {
            Glide.with(mContext).load(Urls.Base_Url+it)
                    .apply(GlideUtils.loadOption())
                    .into(img as ImageView)
        }
    }
}